from toee import *
from utilities import *
from InventoryRespawn import *

def san_dialog( attachee, triggerer ):
	if (game.leader.reputation_has(32) == 1 or game.leader.reputation_has(30) == 1 or game.leader.reputation_has(29) == 1):
		attachee.float_line(11004,triggerer)
	else:
		mycr = find_container_near( attachee, 1053 )
		if (mycr != OBJ_HANDLE_NULL and game.global_vars[705] == 0):
				triggerer.begin_dialog( attachee, 250 )
		triggerer.begin_dialog( attachee, 1 )
	return SKIP_DEFAULT

def san_heartbeat( attachee, triggerer ):
	if (game.global_flags[875] == 1 and game.global_flags[876] == 0 and game.quests[101].state != qs_completed and not anyone( triggerer.group_list(), "has_item", 12900 )):
		game.global_flags[876] = 1
		game.timevent_add( amii_dies, (), 140000000 )
	if (game.story_state >= 3):
		for chest in game.obj_list_vicinity(attachee.location,OLC_CONTAINER):
			if (chest.name == 1053):
				return RUN_DEFAULT
		mycr = game.obj_create( 1053, location_from_axis (572L, 438L) )
		mycr.rotation = 2.5
	return RUN_DEFAULT

def amii_dies():
	game.quests[101].state = qs_botched
	return RUN_DEFAULT

def master( attachee, triggerer ):
	npc = find_container_near(attachee,1001)
	#npc.obj_set_int( obj_f_container_inventory_source, 341 )
	game.timevent_add( RespawnInventory, ( npc, 341 ), 86400000 ) #86400000ms is 24 hours
	return RUN_DEFAULT